﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using agvcontroller.Process;
using agvcontroller.Control;
using agvcontroller.Common;
using agvcontroller.Log;
using agvcontroller.Common.DataBase;

namespace agvcontroller.GUI
{
    /// <summary>
    /// Interaction logic for UCManualControl.xaml
    /// </summary>
    public partial class UCManualControl : UserControl
    {
        CNodeDic NodeDic;
        CAGVController AGVC;
        CVehicle Vehicle;

        public UCManualControl()
        {
            InitializeComponent();

            NodeDic = CNodeDic.getInstance();

            AGVC = CAGVController.getInstance();

            InitUI();

        }

        public void SetVehicle(CVehicle vehicle)
        {
            Vehicle = vehicle;

            SetUI();
        }

        void InitUI()
        {
            cbSourceNode.Items.Clear();
            cbDestNode.Items.Clear();

            foreach (KeyValuePair<int, CNode> node in NodeDic)
            {
                cbSourceNode.Items.Add(node.Key);
                cbDestNode.Items.Add(node.Key);
            }

            cbSourceNode.SelectedIndex = 0;
            cbDestNode.SelectedIndex = 0;

            cbAction.Items.Clear();
            foreach (string action in CCommonInfo.ActionType.ActionTypeList)
            {
                cbAction.Items.Add(action);
            }

            cbAction.SelectedIndex = 0;
        }

        void SetUI()
        {

        }

        private void btnStop_Click(object sender, RoutedEventArgs e)
        {
        }

        private void btnRelease_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnTransferJob_Click(object sender, RoutedEventArgs e)
        {
            AGVC.JobManager.RequestManualJob(Convert.ToInt32(cbSourceNode.SelectedValue), 
                Convert.ToInt32(cbDestNode.SelectedValue), cbAction.SelectedValue.ToString(), 
                tbCarrierID.Text, Vehicle.ID);
        }
    }
}
